package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.AreaService;
import com.yixun.qfbao.apidto.GetCityForOtherReqDto;
import com.yixun.qfbao.apidto.GetCityForOtherResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetCityForOtherReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 获取城市列表
 * @author sangtao
 * @create 2019-2-1
 **/
@Service("GetCityForOtherHander")
public class GetCityForOtherHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(GetCityForOtherHander.class);
    @Autowired
    private AreaService areaService;

    @SuppressWarnings("rawtypes")
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        GetCityForOtherReqVo req = (GetCityForOtherReqVo)reqDto;
        GetCityForOtherReqDto getCityForOtherReqDto = req.getParams();
        BaseResponseDTO<GetCityForOtherResDto> res = new BaseResponseDTO<GetCityForOtherResDto>();
        GetCityForOtherResDto resDto = new GetCityForOtherResDto();
        try {
            resDto = areaService.getCity(getCityForOtherReqDto);
        } catch (Exception e) {
            logger.error("GetCityForOtherHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setMessage("获取市失败");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResult());
        return res;
    }
}
